package com.redoop.bigdatamaker.police;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import com.redoop.bigdatamaker.utils.MakerUtils;
import com.redoop.bigdatamaker.utils.WhenUtils;
import com.redoop.bigdatamaker.utils.WhereUtils;
import com.redoop.bigdatamaker.utils.WhoUtils;

public class TrainMake {

	public static void main(String[] args) {
		String dataType = args[0];
		int count = Integer.parseInt(args[1]);
		System.out.println(dataType + "Maker:" + count);

		OutputStream out = null;
		BufferedWriter rd = null;
		try {
			out = new FileOutputStream("train.txt");
			rd = new BufferedWriter(new OutputStreamWriter(out, "utf-8"));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		for (int i = 0; i < count; i++) {
			String name = MakerUtils.randomGet(MakerUtils.surname) + "" + MakerUtils.randomGet(MakerUtils.name);
			String sexNation = MakerUtils.randomGet(MakerUtils.sex) + "," + MakerUtils.randomGet(MakerUtils.nation);
			String card = WhoUtils.makeidCardNumber();
			String birthday = WhoUtils.randomBirthday();
			String address = MakerUtils.randomGet(MakerUtils.province);
			String trainStation = WhereUtils.getTrainName();
			String time = WhenUtils.randomDate();

			String s = i + "," + name + "," + card + "," + sexNation + "," + birthday + "," + address + ","
					+ trainStation + "," + time;
			try {
				rd.write(s + "\n");

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			System.out.println(i + "," + name + "," + card + "," + sexNation + "," + birthday + "," + address + ","
					+ trainStation + "," + time);
		}
		try {
			rd.close();
			out.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
